﻿using System.Linq;
using System.Collections.Generic;
using cludg.Domain.Content.Stories;
using cludg.Web.Core.ViewModels;

namespace cludg.Web.ViewModels
{
	public class CommentDetailsModel : ITreeNode<Comment>
	{
		public IEnumerable<ITreeNode<Comment>> ChildNodes
		{
			get { return from childComment in Value.ChildComments select new CommentDetailsModel(childComment, CanReplay, CanManage); }
		}

		public Comment Value { get; private set; }

		public bool HasChildren
		{
			get { return Value.ChildComments != null && Value.ChildComments.Any(); }
		}

		public bool CanReplay { get; private set; }

		public bool CanManage { get; private set; }

		public CommentDetailsModel(Comment value, bool canReplay, bool canManage)
		{
			Value = value;
			CanReplay = canReplay;
			CanManage = canManage;
		}
	}
}